/**
 * 通知管理初始化
 */
var InitPortalData = {
    processInterval:null
};



$(function () {
    $('#startDate').datebox();
    $('#endDate').datebox();
    $('#processbar').progressbar({
        value: 0
    });
    //获取评估按钮的长度
    var btnWidth = $("#manual").width();
    $("#processbar").width(btnWidth);
    $(".progressbar-text").width(btnWidth);

});

/**
 * 手动生成数据
 */


InitPortalData.manual = function(){
    var startDate = $('#startDate').datebox('getValue');//开始日期
    var endDate = $('#endDate').datebox('getValue');//结束日期
    var patientId = $("#patientid").val();
    if(startDate==""&&endDate==""&&patientId==""){
        Sys.info("请选择对应日期或就诊号")
        return ;
    }
    if (startDate != "") {
        startDate = startDate + " 00:00:00";
    }
    if (endDate != "") {
        endDate = endDate + " 23:59:59";
    }

    var ajax = new $ax(Sys.backendPath + "/sds/common/initPortalDataMrList", function (data) {

    }, function (data) {
        Sys.error("评估出错!");
    });
    ajax.setBeforSend(InitPortalData.processInterval = setInterval(InitPortalData.process, 1000));
    ajax.set({startDate: startDate,endDate:endDate,patientId:patientId});
    ajax.setAsync(true);
    ajax.start();
}
InitPortalData.process = function(){
    //{"code":200,"message":"操作成功","v":100,"i":"done"}
    var ajaxProcess = new $ax(Sys.backendPath + "/sds/common/getProcess", function(data){
        $('#processbar').progressbar('setValue', data.v);
        //刷新进度条
        if(data.v=="100"){
            clearInterval(InitPortalData.processInterval);
        }
    },function(data){
        Sys.error("获取进度出错!" + data.responseJSON.message + "!");
    });
    ajaxProcess.setAsync(true);
    ajaxProcess.start();
}

InitPortalData.emrNlp = function(){
    var startDate = $('#startDate').datebox('getValue');//开始日期
    var endDate = $('#endDate').datebox('getValue');//结束日期
    var patientId = $("#patientid").val();
    if(startDate==""&&endDate==""&&patientId==""){
        Sys.info("请选择对应日期或就诊号")
        return ;
    }
    if (startDate != "") {
        startDate = startDate + " 00:00:00";
    }
    if (endDate != "") {
        endDate = endDate + " 23:59:59";
    }

    var ajax = new $ax(Sys.backendPath + "/sds/common/analysisEmrData", function (data) {

    }, function (data) {
        Sys.error("解析出错!");
    });
    ajax.setBeforSend(InitPortalData.processInterval = setInterval(InitPortalData.emrProcess, 1000));
    ajax.set({startDate: startDate,endDate:endDate,patientId:patientId});
    ajax.setAsync(true);
    ajax.start();
}

InitPortalData.examNlp = function(){
    var startDate = $('#startDate').datebox('getValue');//开始日期
    var endDate = $('#endDate').datebox('getValue');//结束日期
    var patientId = $("#patientid").val();
    if(startDate==""&&endDate==""&&patientId==""){
        Sys.info("请选择对应日期或就诊号")
        return ;
    }
    if (startDate != "") {
        startDate = startDate + " 00:00:00";
    }
    if (endDate != "") {
        endDate = endDate + " 23:59:59";
    }

    var ajax = new $ax(Sys.backendPath + "/sds/common/analysisExamData", function (data) {

    }, function (data) {
        Sys.error("解析出错!");
    });
    ajax.setBeforSend(InitPortalData.processInterval = setInterval(InitPortalData.emrProcess, 1000));
    ajax.set({startDate: startDate,endDate:endDate,patientId:patientId});
    ajax.setAsync(true);
    ajax.start();
}

InitPortalData.emrProcess = function(){
    //{"code":200,"message":"操作成功","v":100,"i":"done"}
    var ajaxProcess = new $ax(Sys.backendPath + "/sds/common/getEmrProcess", function(data){
        $('#processbar').progressbar('setValue', data.v);
        //刷新进度条
        if(data.v=="100"){
            clearInterval(InitPortalData.processInterval);
        }
    },function(data){
        Sys.error("获取进度出错!" + data.responseJSON.message + "!");
    });
    ajaxProcess.setAsync(true);
    ajaxProcess.start();
}